import easygui as g
import pyautogui  # pip install opencv-python pyautogui easygui wxpython
from inc import *
import time
def pos():
    # r_location = pyautogui.locateOnScreen(str(root/"ES1.png"), confidence=0.8, grayscale=True)
    try:
        r_location = pyautogui.locateOnScreen(str(root/"ES1.png"), confidence=0.8, grayscale=True)
    except  pyautogui.ImageNotFoundException :
        g.msgbox("图像未找到！")
        return False
    if(r_location!=None):
        
        mouse_x=r_location[0]+60
        mouse_y=r_location[1]+80
        print(r_location)
        pyautogui.moveTo(mouse_x,mouse_y)
    else:
        g.msgbox("定位失败")
while 1:
    answer=[]
    t=g.textbox("输入")
    tx=""
    for i in t :
        if i in ["A","B","C","D","E","F","G","H","T"]:
            answer.append(i)
            tx=tx+i+"\n"
    # pos()
    # pyautogui.click()
    # for i in answer:
    #     pyautogui.typewrite(i)
    #     pyautogui.press("down") 
    t1=tx[:-10]
    t2=tx[-10:]
    t1=t1.replace('T',"A")
    t1=t1.replace("F","B")
    tx=t1+t2
    tx=""
    for i in range(len(answer)):
        tss=""
        if(i<len(answer)-10):
            if(answer[i]=="T" or answer[i]=="t"):
                tss="A"
            elif(answer[i]=="F" or answer[i]=="f"):
                tss="B"
            else:
                tss=answer[i]
        else:
            tss=answer[i]
        tx+=f"{i+1}\tS\t{tss}\t2\n"
        print(answer[i],i)
    t=g.textbox("答案",text=tx)
    print(answer)
